package testgrails

import java.util.Date;

/*
A Customer represents an account required to list or bid at AuctionHaus. Customers have the following requirements:
C-1: Customers have email address, password and created date fields (unit test)
C-2: Email address must be a unique field (integration test)
C-3: Email address must be of a valid form (@.*) (unit test)
C-4: Password must be between 6-8 characters (unit test)
*/
class Customer {
	String emailAddress
	String password
	Date dateCreated

	//TODO: Email format reg-ex check not added
	//'[a-zA-Z0-9]+@[a-zA-Z0-9]+\\.[a-zA-Z]{2,4}' //todo
	   static constraints = {
		   //Should we use email: true(email validator) as well??
			emailAddress nullable: true, unique: true//, matches: /@.*/ 
			password nullable: false, size: 6..8 
		}
}

/**
  MC -- Looks pretty close to mine, although I have these relationships declared:
  
  	static hasMany = [bids: Bid, listings: Listing, winnings: Listing]
	  static mappedBy = [listings:'seller', winnings:'winner'];
     
    This allows the user to have many bids, many listings, and many winnings
    
    Also -- for the email, I don't think you need to use regex, you can just use the built in email checker:
    
    		emailAddress(email:true, unique:true)

    I'm also wondering why you have it as nullable.. If it is unique, having it nullable is a problem.
    
    
*/